//
//  FriendItem.m
//  ChangChat
//
//  Created by Cocoa on 2019/9/3.
//  Copyright © 2019 yibai. All rights reserved.
//

#import "FriendItem.h"
#import <LKDBHelper/LKDBHelper.h>


@implementation FriendItem

+ (NSString *)getPrimaryKey {
    return @"friend_id";
}

- (BOOL)isFriend {
//    for (FriendItem *item in kUsermanager.friendArray) {
//        if ([item.friend_id isEqualToString:self.ID] == YES) {
//            return YES;
//        }
//    }
    if (self.is_friend == YES) {
        return YES;
    }
    if ([self.friend_id isEqualToString:kUsermanager.me.ID] == YES) {
        return YES;
    }
    return NO;
}
- (BOOL)isMe {
    if ([self.friend_id isEqualToString:kUsermanager.me.ID] == YES) {
        return YES;
    } else {
        return NO;
    }
}
- (NSString *)displayName {
    return self.nickname.isHaveStr ? self.nickname : self.username;
}
- (NSString *)getCardJson {
    NSDictionary *json = @{@"id": self.friend_id?:@"",
                           @"avatar": self.avatar?:@"",
                           @"username": self.username?:@"",
                           @"mobile": self.mobile?:@""
                           };
    
    return [json mj_JSONString];
}
@end
